/* 
 * File:   list.h
 * Author: aishwarya
 *
 * Created on March 12, 2011, 5:40 AM
 * Linked List
 */
#include "avdtech.h"

#ifndef LIST_H
#define	LIST_H

#ifdef	__cplusplus
extern "C" {
#endif

    typedef struct _list_node {
        struct _list_node *next; /* pointer to next node */
        char *data; /* data stored in the node */
    } list_node;

    typedef struct _linklist {
        struct _linklist *THIS;

        /* Functions to compare, print, copy, delete the elements of this list */
        KEYCMP _keycmpfn;
        DATACPY _datacpyfn;
        DELNODE _delnodefn;
        PRINTNODE _printfn;

        size_t e_size; /* Size of one element */
        list_node *head; /* pointer to the head of the list */
        list_node *tail; /* pointer to the tail of the list */
    } linklist;

    void list_init(linklist *l, size_t e_size, KEYCMP k, DATACPY d, DELNODE n, PRINTNODE p);
    void list_add(linklist *l, const void *n);
    void list_traverse(const linklist *l);
    void list_clean(linklist *l);

#ifdef	__cplusplus
}
#endif

#endif	/* LIST_H */

